package IO.g4;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Aufgabe4Test {

	public static void main(String[] args) throws IOException {
		
		Student s = new Student("Horst", 123, "Jura");
		Student s2 = new Student("Ulrike", 456,"Medizin");
		
		Student[] moreStudents = new Student[2];
		moreStudents[0] = s;
		moreStudents[1] = s2;
		
		BufferedWriter bw = new BufferedWriter(
				new FileWriter("oneStudent.txt",true));
		
		BufferedWriter bw2 = new BufferedWriter(
				new FileWriter("moreStudents.txt",true));
		
		s.writeData(bw);
		Student.writeData(bw2, moreStudents);
		
		BufferedReader br = new BufferedReader(new FileReader("oneStudent.txt"));
		BufferedReader br2 = new BufferedReader(new FileReader("moreStudents.txt"));
		
		Student read = s.readData(br);
		Student[] students = Student.readData(br2, 2);
		
		
		System.out.println("Student name: " + read.getName());
		
		System.out.println("Student2 name: " + students[0].getName());
		System.out.println("Student3 name: " + students[1].getName());
	}

}
